﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace darkeggs
{
    class gogo
    {
        Vector2 position;
        Vector2 prevPosition;
        Vector2 dimensions = new Vector2(64, 64);
        List<Color> selectedColor;
        Texture2D TEXTURE;

        float speed = 1.0f;

        public gogo(Texture2D texture, Vector2 pos)
        {
            position = pos;
            TEXTURE = texture;
        }
        /*Direction Guide
         * 1. Right
         * 2. Down
         * 3. Left
         * 4. Up
         * 5. Up-Right
         * 6. Up-Left
         * 7. Down-Left
         * 8. Down-Right
         */
        public void moveGogo(int direction)
        {
            if (direction >= 1 && direction <= 8)
                prevPosition = position;
            switch (direction)
            {
                case 1:
                    if (position.X + dimensions.X < 1024)
                        position.X += speed;
                    break;
                case 2:
                    if (position.Y + dimensions.Y < 768)
                        position.Y += speed;
                    break;
                case 3:
                    if (position.X > 0)
                        position.X -= speed;
                    break;
                case 4:
                    if (position.Y > 0)
                        position.Y -= speed;
                    break;
                case 5:
                    if (position.X + dimensions.X < 1024 && position.Y + dimensions.Y < 768)
                    {
                        position.X += speed;
                        position.Y -= speed;
                    }
                    break;
                case 6:
                    if (position.X > 0 && position.Y > 0)
                    {
                        position.X -= speed;
                        position.Y -= speed;
                    }
                    break;
                case 7:
                    if (position.X > 0 && position.Y + dimensions.Y < 768)
                    {
                        position.X -= speed;
                        position.Y += speed;
                    }
                    break;
                case 8:
                    if (position.X + dimensions.X < 1024 && position.Y + dimensions.Y < 768)
                    {
                        position.X += speed;
                        position.Y += speed;
                    }
                    break;
                default:
                    break;
            }
        }

        public void drawTexture(SpriteBatch sb)
        {
            Rectangle temp = new Rectangle((int)position.X, (int)position.Y, (int)dimensions.X, (int)dimensions.Y);
            sb.Draw(TEXTURE, temp, Color.White);
        }
        

        public List<Vector2> getPos()
        {
            List<Vector2> temp = new List<Vector2>();
            temp.Add(position);
            temp.Add(new Vector2(position.X+dimensions.X,position.Y));
            temp.Add(new Vector2(position.X,position.Y+dimensions.Y));
            temp.Add(new Vector2(position.X+dimensions.X,position.Y+dimensions.Y));

            temp.Add(new Vector2(position.X + (dimensions.X/2), position.Y ));
            temp.Add(new Vector2(position.X + (dimensions.X/2), position.Y + dimensions.Y));

            temp.Add(new Vector2(position.X + dimensions.X, position.Y + (dimensions.Y/2)));
            temp.Add(new Vector2(position.X , position.Y + (dimensions.Y/2)));


            return temp;
        }

        public Vector2 getArmPosition()
        {
            Vector2 temp = new Vector2(position.X + (dimensions.X / 2), position.Y);
            return temp;
        }

        public void prevPos()
        {
            position = prevPosition;
        }
        
    }
}
